<?php

function getStyle($int) {
    switch ($int % 2) {
        case 0:
            $style = "even";
            break;
        case 1:
            $style = "odd";
            break;
    }
    return $style;
}

function getTableHeader($string) {
    switch ($string) {
        case "SC":
            controllerCharacter::getOverviewHeader();
            break;
        case "NSC":
            controllerCharacter::getNscHeader();
            break;
        case "RP":
            controllerCharacter::getRoleplayHeader();
            break;
        case "G":
            controllerCharacter::getGuildHeader();
            break;
        default:
            controllerCharacter::getOverviewHeader();
            break;
    }
}

function getTableRows($type, $table) {
    $sql = "SELECT * FROM  `character` WHERE  `type` =  '" . $type . "'";
    $query = MySql::query($sql);
        while ($row = mysql_fetch_object($query)) {
            $i = 1;
            echo "<tr class =";
            echo getStyle($i);
            echo " id='";
            echo $row->_id;
            echo "'\">";
            switch ($table) {
                case "SC":
                    controllerCharacter::getOverviewRow($row);
                    break;
                case "RP":
                    controllerCharacter::getRoleplayRow($row);
                    break;
                case "G":
                    controllerCharacter::getGuildRow($row);
                    break;
                case "NSC":
                    controllerCharacter::getNscRow($row);
                    break;
                default:
                    controllerCharacter::getOverviewRow($row);
                    break;
            }
            echo "</tr>";
            $i++;
        }
}

function getHierarchyParents() {
    $sql = "select c.`surname`, (select o.`name` from `organisation` o where o.`_id` = c.`_oid`) as `organisation` from `character` c where  NOT EXISTS ( select 1 from `hierarchy` h where h.`_id` = c.`_id`)";
    return MySql::query($sql);
}

function getAdminTableRows() {
    $sql = "SELECT * FROM  `character`";
    $query = MySql::query($sql);
    while ($row = mysql_fetch_object($query)) {
        $i = 1;
        echo "<tr class =";
        echo getStyle($i);
        echo " id='";
        echo $row->_id;
        echo "'\">";
        controllerCharacter::getAdminRow($row);
        echo "</tr>";
        $i++;
    }
}

?>
